#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2018, Niklas Hauser
# Copyright (c) 2017, Fabian Greif
# Copyright (c) 2020, Erik Henriksson
# Copyright (c) 2021, Jeff McBride
# Copyright (c) 2021-2022, Christopher Durand
# Copyright (c) 2023, Thomas Rush
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------

def init(module):
    module.name = ":board:feather-m4"
    module.description = FileReader("module.md")

def prepare(module, options):
    if not options[":target"].partname == "samd51j19a-au":
        return False

    module.depends(
        ":debug",
        ":platform:gclk",
        ":platform:gpio",
        ":platform:core",
        ":platform:usb",
        ":platform:uart:5")

    return True

def build(env):
    env.outbasepath = "modm/src/modm/board"
    env.substitutions = {
        "with_logger": True,
        "with_assert": env.has_module(":architecture:assert"),
    }
    env.template("../board.cpp.in", "board.cpp")
    env.copy('.')


